package com.work.shart.common.mybatis.service.impl;

import com.work.shart.common.mybatis.service.IBaseService;
import com.work.shart.common.mybatis.service.SuperService;
import org.springframework.beans.factory.annotation.Autowired;

import java.lang.reflect.ParameterizedType;

public class SuperServiceImpl<S extends IBaseService<Entity>, Entity> implements SuperService<Entity> {
    Class<Entity> entityClass = null;
    @Autowired
    protected S baseService;

    @Override
    public Class<Entity> getEntityClass() {
        if (entityClass == null) {
            this.entityClass = (Class<Entity>) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[1];
        }
        return this.entityClass;
    }

    @Override
    public IBaseService<Entity> getBaseService() {
        return baseService;
    }

}
